from socket import *


def main():
    # 创建udp套接字
    udp_socket = socket(AF_INET, SOCK_DGRAM)

    # 绑定端口
    local_addr = ('', 8080)
    udp_socket.bind(local_addr)

    # 接收方信息
    dest_addr = ('192.168.10.167', 9999)
    send_data = input("请输入要发送的数据：")
    udp_socket.sendto(send_data.encode('utf-8'), dest_addr)

    # 关闭套接字
    udp_socket.close()


if __name__ == '__main__':
    main()
